package com.hk.admin.module.system.controller;

import com.hk.admin.common.base.controller.BaseController;
import com.hk.admin.common.base.dto.message.Message;
import com.hk.admin.common.dto.system.menu.MenuDTO;
import com.hk.admin.module.system.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <br>
 * <b>功能：</b>系统菜单<br>
 * <b>作者：</b>Pan.ShiJu<br>
 * <b>日期：</b>2017/4/11 23:27<br>
 */
@RestController
@RequestMapping("/menu")
public class MenuController extends BaseController {

    @Autowired
    private MenuService menuService;

    /**
     * 列表数据
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public ResponseEntity<Message> list() {
        return menuService.list();
    }

    /**
     * 查询一个
     */
    @RequestMapping(value = "/query/{id}", method = RequestMethod.GET)
    public ResponseEntity<Message> query(@PathVariable("id") Long id) {
        return menuService.query(id);
    }

    /**
     * 保存、更新
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public ResponseEntity<Message> save(@RequestBody MenuDTO dto) {
        return menuService.save(dto);
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public ResponseEntity<Message> delete(@PathVariable("id") Long id) {
        return menuService.delete(id);
    }

}
